#include <stdio.h>
int main(void)
{
	int n,i,c=1,sum=1,x;
	scanf("%d%d",&x,&n);
	for(i=1;i<=n;i++){
       c=c*x;
	   sum=sum+c;
	}
	printf("sum=%d\n",sum);
	return 0;
}
